package com.ruoyi.app.controller;

import com.ruoyi.app.utils.AjaxResult;
import com.ruoyi.web.wuliu.domain.AppUser;
import com.ruoyi.web.wuliu.service.IAppUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "小程序端-用户操作")
@RestController
@RequestMapping("/app/user")
public class AppUserController {

    @Autowired
    private IAppUserService appUserService;

    /**
     * 注册车辆
     */
    @ApiOperation("注册车辆")
    @PostMapping("/signIn")
    @ApiImplicitParam(name = "user", value = "注册车辆", dataType = "AppUser")
    public AjaxResult<String> signIn(@RequestBody AppUser user) {
        return appUserService.signIn(user);
    }


    /**
     * 修改车辆信息
     */
    @ApiOperation("修改车辆信息")
    @PostMapping("/edit")
    @ApiImplicitParam(name = "user", value = "修改车辆信息", dataType = "AppUser")
    public AjaxResult<String> edit(@RequestBody AppUser user) {
        return appUserService.signIn(user);
    }


    /**
     * 司机信息
     */
    @ApiOperation("司机信息")
    @GetMapping("/get/{id}")
    public AjaxResult<AppUser> get(@PathVariable String id) {
        System.out.println("参数id:"+id);
        return AjaxResult.success(appUserService.newSelectAppUserById(id));
    }

}
